/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.lodz.p.ftims.ProjektZespolowy2.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Łukasz Gadomski
 */
@Entity
@Table(name = "days_of_week")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DayOfWeek.findAll", query = "SELECT d FROM DayOfWeek d"),
    @NamedQuery(name = "DayOfWeek.findByDayId", query = "SELECT d FROM DayOfWeek d WHERE d.dayId = :dayId"),
    @NamedQuery(name = "DayOfWeek.findByName", query = "SELECT d FROM DayOfWeek d WHERE d.name = :name")})
public class DayOfWeek implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "day_id")
    private Integer dayId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "dayId")
    private Collection<WorkingDay> workingDaysCollection;

    public DayOfWeek() {
    }

    public DayOfWeek(Integer dayId) {
        this.dayId = dayId;
    }

    public DayOfWeek(Integer dayId, String name) {
        this.dayId = dayId;
        this.name = name;
    }

    public Integer getDayId() {
        return dayId;
    }

    public void setDayId(Integer dayId) {
        this.dayId = dayId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<WorkingDay> getWorkingDaysCollection() {
        return workingDaysCollection;
    }

    public void setWorkingDaysCollection(Collection<WorkingDay> workingDaysCollection) {
        this.workingDaysCollection = workingDaysCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dayId != null ? dayId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DayOfWeek)) {
            return false;
        }
        DayOfWeek other = (DayOfWeek) object;
        if ((this.dayId == null && other.dayId != null) || (this.dayId != null && !this.dayId.equals(other.dayId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.lodz.p.ftims.ProjektZespolowy2.entities.DaysOfWeek[ dayId=" + dayId + " ]";
    }
    
}
